package com.newland.starpos.partner.mvc.converter;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * Created by liuNW on 2018/9/29.
 */
@Slf4j
public class CustomJackson2Converter extends MappingJackson2HttpMessageConverter {

    @Override
    protected void writeInternal(Object object, Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
        String response = JSON.toJSONString(object);
        log.info("response data:{}", response);
        super.writeInternal(object, type, outputMessage);
    }
}
